<?php
class ContactPage extends UserDefinedForm {
	public static $db = array(
        'ContactName'    => 'Varchar(255)',
        'ContactAddress' => 'Varchar(255)',
        'ContactPhone'   => 'Varchar(100)',
        'ContactFax'     => 'Varchar(100)',
        'ContactEmail'   => 'Varchar(255)',
        'GMapKey'        => 'Varchar(100)',
        'GMapLat'        => 'Varchar(100)',
        'GMapLong'       => 'Varchar(100)',
	);
	
	public static $has_one = array(
        'Image'    => 'Image',
	);

	function getCMSFields(){
		$fields = parent::getCMSFields();
		
        $fields->addFieldToTab('Root.Content.Main', new TextField('ContactName', 'Contact name'), 'Content');
        $fields->addFieldToTab('Root.Content.Main', new TextField('ContactAddress', 'Address'), 'Content');
        $phone = new FieldGroup(
            new TextField('ContactPhone', 'Phone'),
            new LiteralField('PhoneLabel0', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'),
            new TextField('ContactFax', 'Fax'),
            new LiteralField('PhoneLabel1', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'),
            new EmailField('ContactEmail', 'Email', '', 150)
        );
        $fields->addFieldToTab('Root.Content.Main', $phone, 'Content');
        
        $gmap = new FieldGroup(            
            new TextField('GMapKey', 'GoogleMap key'),
            new LiteralField('GMapLabel1', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'),
            new TextField('GMapLat', 'Latitudes'),
            new LiteralField('GMapLabel2', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'),
            new TextField('GMapLong', 'Longitudes')
        );
        $gmap->setTitle('GoogleMap configuration');
        $fields->addFieldToTab( 'Root.Content.Main', $gmap, 'Content'); 
        
        $fields->addFieldToTab('Root.Content.Main', new ImageField('Image', 'Call us image (Recommended size: 227 x 49)'), 'Content');
        
		$news = new DataObjectManager(
            $this,
            'News',
            'News',            
             array(
                'Title'		=> 'Title',
				'IntroText'	=> 'Content'
             ),
            'getCMSFields_forPopup'
        );
        $news->setAddTitle('news');      
        $fields->addFieldToTab('Root.Content.News', $news); 
		
		return $fields;
	}
}

class ContactPage_Controller extends UserDefinedForm_Controller {	
	public function init() {        
		parent::init();		
	}
}